package edu.gatech.oad.antlab.m7final;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;


public class FrameHolder {
	private JFrame current;
	public Intro intro;
	public ConfigFrameM5 party;
	public StoreFrameM6 store;
	public JButton load;
	public JButton trail;
	public JButton continueTrail;
	public JButton returnBack;
	public JPanel buttons;
	public TrailFrame trailFrame;
	private ButtonListener listener;
	private WagonController wagonController;
	public FrameHolder(){
		
		intro = new Intro();
		load =  (JButton)intro.getLoadButton();
		load.setVisible(true);
		
		listener = new ButtonListener();
		load.addActionListener(listener);
		trail  = (JButton)intro.getTrailButton();
		trail.addActionListener(listener);
		trail.setVisible(true);
		
		
		
		
		
		intro.setVisible(true);
		//party.setVisible(false);


		
		current = intro;

		
		

	}
	
	
	public static void main(String[] args){
		new FrameHolder();

	}
	

	
	private class ButtonListener implements ActionListener{
		public void actionPerformed(ActionEvent e){
			if(e.getSource() == load)
			System.out.println("load clicked");
			if(e.getSource()== trail){
				party = new ConfigFrameM5(wagonController); // Create new party frame
				continueTrail = (JButton)party.getContinue();
				continueTrail.addActionListener(listener);
				load.doClick(10);
				party.setVisible(true);
				current.setVisible(false);
				current = party;
			}
			if(e.getSource()== continueTrail){
				wagonController = party.getWagonControlller();
				store = new StoreFrameM6(wagonController);
				store.setVisible(true);
				current.setVisible(false);
				returnBack = store.getReturn();
				returnBack.addActionListener(listener);
				current = store;
			}
			if(e.getSource()== returnBack){
				trailFrame = new TrailFrame(wagonController);
				current.setVisible(false);
				trailFrame.setVisible(true);
				
				current = trailFrame;
			}
		}
	}
}
